home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
batch
/
bat_com
/
runppdos.asm
< prev
Wrap
Assembly Source File
|
1989-01-28
|
10KB
|
304 lines
comment *
This is a program to take the place of a simple batch file. It's
mostly intended for use with Desqview. In Desqview, if a program
runs from a batch file, COMMAND.COM must be loaded to interpret the
batch file.
If the batch file does nothing more than set up the environment
and call several programs in sequence, this program can replace it.
This opens up more room in the window for the main program to use.
(The way you tell Desqview not to load COMMAND.COM is to explicitly
include a .COM or .EXE extension in the "Program name" field).
This program must be modified and re-asembled for each different
incarnation. See lines 62 - 120 below for what must be changed.
This will not work with programs that inspect the default FCB fields
of the PSP for their first two command line arguments, since I got
lazy and didn't use int 21h function 29h to parse the command line
into an FCB.
This is a COM program. It must be "exe2bin'd". To create
RUNPPDOS.COM:
MASM RUNPPDOS;
LINK RUNPPDOS;
EXE2BIN RUNPPDOS.EXE RUNPPDOS.COM
This particular incarnation of the program runs a mouse driver,
Fakey to put PopDOS into split screen mode, and then PopDOS
Jon Fleming (BIX: jfleming) 12/20/88
Released into the public domain 1/29/89
*
cr equ 0dh
lf equ 0ah
space equ 20h
tab equ 9
stdin equ 0
stdout equ 1
stderr equ 2
stdaux equ 3
stdprn equ 4
stack_size equ 256 ;bytes set aside for stack
stack segment stack ;this just keeps the linker quiet
stack ends
program group code,data
code segment
data segment para ;environment has to be paragraph aligned
;Put the environment you want here. Each string should be CAPITALIZED,
;and terminated with a 00 byte. Terminate the whole environment with
;two 00 bytes.
;Note that you must set up the WHOLE environment, this program is not
;smart enough to copy anything from its environment. A PATH and COMSPEC
;are the minimum you should set up.
environment label byte
db "PATH=E:\;C:\BATCH;C:\DOS;F:\;G:\;H:\;I:\;C:\",0
db "PROMPT=$P$G",0
db "COMSPEC=E:\COMMAND.COM",0
db 0
;put the FULL PATHNAME of the first program you want to run here, again
;terminated by a 00 byte. BE SURE to include the .COM or .EXE
mouse_driver_name db "C:\ORGANIZE\MOUSE\MOUSE.COM",0
;Here's how a command tail is handled. First a length byte (not including
;the length byte itself or the carriage return at the other end).
mouse_driver_cmd_tail db end_md_cmd_tail-mouse_driver_cmd_tail-2
;then the command tail itself, terminated by a carriage return
db " 2 ser bon",cr
end_md_cmd_tail label byte
keyfake_name db "E:\FAKEY.COM",0
keyfake_cmd_tail db end_keyfake_cmd_tail-keyfake_cmd_tail-2
db " F3",cr
end_keyfake_cmd_tail label byte
;and a third program, with no command tail
popdos_name db "C:\ORGANIZE\MOUSE\POPDOS.EXE",0
;a null command line for any programs that don't need a command line
null_cmd_tail db 0,cr
;Now we have a table of addresses of the program names and their
;command lines
program_table label word
mouse_name_addr dw offset program:mouse_driver_name
mouse_cmd_tail_addr dw offset program:mouse_driver_cmd_tail
keyfake_name_addr dw offset program:keyfake_name
keyfake_cmd_tail_addr dw offset program:keyfake_cmd_tail
popdos_name_addr dw offset program:popdos_name
popdos_cmd_tail_addr dw offset program:null_cmd_tail
;and the program table is terminated by a 0000 word
end_program_table dw 0
;The following is a block of parameters for the MS-DOS function that
;executes the programs
exec_parameter_block label byte
environment_paragraph dw ?
cmd_tail_offset dw ?
cmd_tail_segment dw ?
fcb_1_offset dw -1 ;no FCBs set up
fcb_1_segment dw -1
fcb_2_offset dw -1
fcb_2_segment dw -1
;A simple error message
error_msg db cr,lf,"EXEC failed, AL= 0"
error_code db 2 dup (?)
db "h",cr,lf
error_msg_length equ $ - error_msg
;storage for the SS and SP registers which will be trashed by MS-DOS
:(at least 2.x, I hear 3.x is nicer, but I'm being safe)
stack_segment dw ?
stack_pointer dw ?
;and a marker for the end of the program
end_program label byte ;note that the data will be AFTER
;the code after linking
data ends
;Our Program Segment Prefix
org 2ch
our_envir_seg dw ?
;Program itself
org 100h
assume cs:program,ds:program,es:program,ss:program
begin:
mov es,our_envir_seg
assume es:nothing
mov ah,49h
int 21h ;release our environment
mov ax,cs
mov es,ax ;restore ES
assume es:program
mov bx,offset program:end_program ;end of us in bytes
add bx,stack_size ;add on stack size
cli ;still some early 8088s out there that
;need this
mov sp,bx ;relocate stack
sti
add bx,15
shr bx,1
shr bx,1
shr bx,1
shr bx,1 ;round our size up to paragraphs
mov ah,4ah
int 21h ;shrink our memory allocation to make
;room for other programs
mov bx,offset program:environment
shr bx,1
shr bx,1
shr bx,1
shr bx,1 ;BX has offset of environment for
;other programs (in paragraphs)
mov ax,ds
add ax,bx ;AX has absolute paragraph of
;environment for other programs
mov environment_paragraph,ax ;set up pointer to environment
mov cmd_tail_segment,ds ;set up segment of pointer to command
;tail
mov bp,offset program:program_table ;point to pointer to name of
;first program to run
loop_over_programs:
mov dx,[bp] ;load pointer to name of first
;program to run
or dx,dx
jz exit ;zero means we've reached end of table
inc bp
inc bp ;point to pointer to command tail
mov cx,[bp]
mov cmd_tail_offset,cx ;set up offset of pointer to command
;tail
inc bp
inc bp ;point to pointer to next program name
push bp ;save for later
mov bx,offset program:exec_parameter_block ;pointer
;to parameter block
mov ax,4b00h ;exec function, run program
mov stack_segment,ss
mov stack_pointer,sp ;EXEC trashes these
int 21h
assume ds:nothing,es:nothing,ss:nothing
cli ;for 8088s with bug
mov ss,stack_segment
assume ss:program
mov sp,stack_pointer
sti ;restore stack segment and pointer
mov bx,cs
mov ds,bx
assume ds:program ;restore data segment
mov es,bx
assume es:program ;restore extra segment
jnc get_ready_for_next_prog ;now we can see if the EXEC worked
mov dl,al ;whoops, it didn't; save error code
and al,0Fh ;get one digit worth
daa ;add 6 if A through F
add al,0F0h ;set carry if A-F
adc al,40h ;convert to ASCII
mov error_code+1,al ;and save second digit
rol dl,1
rol dl,1
rol dl,1
rol dl,1 ;get other digit-worth of the byte
;into position
mov al,dl
and al,0Fh ;get one digit worth
daa ;add 6 if A through F
add al,0F0h ;set carry if A-F
adc al,40h ;convert to ASCII
mov error_code, al ;and save first digit
mov dx,offset program:error_msg
mov cx,error_msg_length
mov bx,stderr
mov ah,40h
int 21h ;display error message
get_ready_for_next_prog:
pop bp ;restore pointer to pointer to next
;program name
jmp loop_over_programs ;go do next program
exit:
mov ax,4c00h
int 21h
code ends
end begin